package com.tzz.controller;


import com.tzz.entity.DoOrder;
import com.tzz.entity.HttpResult;
import com.tzz.entity.SkuQty;
import com.tzz.service.DoOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/pre/do/order")
public class DoOrderController {

    @Autowired
    DoOrderService doOrderService;

    @PostMapping("/add")
    public HttpResult<Object> addDoOrder(@RequestBody  DoOrder doOrder){
        doOrderService.produceDoOrder(doOrder);
//        System.out.println(doOrder);
        return HttpResult.success();
    }

    @PostMapping("/query")
    public HttpResult<List<DoOrder>> getDoOrder(@RequestBody HashMap<String,Object> asnId){
        List<DoOrder> doOrders = doOrderService.getDoOrders(asnId);
        return HttpResult.success(doOrders);
    }

    @PostMapping("/query/sku/qty")
    public HttpResult<List<SkuQty>> getSkuQty(@RequestBody HashMap<String,Object> asnId){
        return HttpResult.success(doOrderService.findSkuQty(asnId));
    }
}
